#include <stdio.h>  
#include<malloc.h>
int* twoSum(int* nums, int numsSize, int target, int* returnSize)
{  
    int* result = (int*)malloc(2*sizeof(int));  
    int count = 0;  
    for (int i = 0; i < numsSize; i++) {  
        for (int j = i + 1; j < numsSize; j++) {  
            if (nums[i] + nums[j] == target) {  
                result[count++] = i;  
                result[count++] = j;  
                *returnSize = count;  
                return result;  
            }  
        }  
    }  
    *returnSize = 0;
    return NULL;  
}

int main() 
{  
    int nums[] = {2, 7, 11, 15};  //测试集{2，7，11，15} 
    int target = 9;    //目标为9 
    int returnSize;  
    int* result = twoSum(nums, 4, target, &returnSize);  
    if (result != NULL) {  
        printf("找到两个数的下标为：");  
        for (int i = 0; i < returnSize; i++) {  
            printf("%d ", result[i]);  
        }  
        printf("\n");  
        free(result); 
    } else {  
        printf("未找到符合条件的结果。\n");  
    }  
    return 0;  
}